package excel;

import java.io.*;

import jxl.Workbook;
import jxl.write.*;

public class Excel {
	
	int count;
	Label name;
	Label address;
	Label mobile;
	WritableWorkbook writableWorkbook;
	WritableSheet writableSheet;
	
	public Excel() throws Exception {
		
		count = 0;
		File exlFile = new File("company detail.xls");
		writableWorkbook = Workbook.createWorkbook(exlFile);
		writableWorkbook = Workbook.createWorkbook(exlFile);
		writableSheet = writableWorkbook.createSheet("Sheet1", 0);
		insertRow("Name","Address","Mobile");
		
	}
	
	public void insertRow(String n, String a, String m) throws Exception {
		
		name = new Label(0, count, n );
		address = new Label(1, count, a);
		mobile = new Label(2, count, m);
		
		writableSheet.addCell(name);
	    writableSheet.addCell(address);
	    writableSheet.addCell(mobile);
	    
	    count = count + 1;
	    
	}
	
	public void closeWorkbook() throws WriteException, IOException {
		writableWorkbook.write();
		writableWorkbook.close();
	}
}
